What is the purpose of a pragma Data_Align in TI emb. compiler.
The datasheet explanation:
http://www.ti.com/lit/ug/spnu151j/spnu151j.pdf
"The DATA_ALIGN pragma aligns the symbol in C, or the next symbol declared in C++, to an alignment
boundary. The alignment boundary is the maximum of the symbol's default alignment value or the value of
the constant in bytes. The constant must be a power of 2. The maximum alignment is 32768.
The DATA_ALIGN pragma cannot be used to reduce an object's natural alignment."
Can someone re-explain it in a different method? I really don't understand the purpose of this pre-compile directive.
Best Answer
DATA_ALIGN will cause the symbol to be located at an address that satisfies the specified alignment requirement. For example:
The following code will locate
mybyte
at an even address.The following code will locate
mybuffer
at an address that is evenly divisible by 1024.Most symbols don't require any special alignment beyond the data type's default alignment so you won't need to use DATA_ALIGN often. But occasionally you'll want a symbol to be located on a special address boundary and that's when DATA_ALIGN is useful. For example, sometimes buffers used with a DMA controller should be aligned on a special boundary.